Load all required libraries.
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5 v purrr 0.3.4
## v tibble 3.1.3 v dplyr 1.0.7
## v tidyr 1.1.3 v stringr 1.4.0
## v readr 2.0.0 v forcats 0.5.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(broom)
Read in raw data from RDS.
raw_data <- readRDS("./year2.RDS")
Make a few small modifications to names and data for visualizations.
final_data <- raw_data %>% mutate(log_copy_per_L = log10(mean_copy_num_L)) %>%
rename(Facility = wrf) %>%
mutate(Facility = recode(Facility,
"NO" = "WRF A",
"MI" = "WRF B",
"CC" = "WRF C"))
Seperate the data by gene target to ease layering in the final plot
#make three data layers
only_positives <<- subset(final_data, (!is.na(final_data$Facility)))
only_n1 <- subset(only_positives, target == "N1")
only_n2 <- subset(only_positives, target == "N2")
only_background <<-final_data %>%
select(c(date, cases_cum_clarke, new_cases_clarke, X7_day_ave_clarke)) %>%
group_by(date) %>% summarise_if(is.numeric, mean)
#specify fun colors
background_color <- "#7570B3"
seven_day_ave_color <- "#E6AB02"
marker_colors <- c("N1" = '#1B9E77',"N2" ='#D95F02')
#remove facilty C for now
#only_n1 <- only_n1[!(only_n1$Facility == "WRF C"),]
#only_n2 <- only_n2[!(only_n2$Facility == "WRF C"),]
only_n1 <- only_n1[!(only_n1$Facility == "WRF A" & only_n1$date == "2020-11-02"), ]
only_n2 <- only_n2[!(only_n2$Facility == "WRF A" & only_n2$date == "2020-11-02"), ]
Build the main plot
#first layer is the background epidemic curve
p1 <- only_background %>%
plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~new_cases_clarke,
type = "bar",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Daily Cases: ', new_cases_clarke),
alpha = 0.5,
name = "Daily Reported Cases",
color = background_color,
colors = background_color,
showlegend = FALSE) %>%
layout(yaxis = list(title = "Clarke County Daily Cases", showline=TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#renders the main plot layer two as seven day moving average
p1 <- p1 %>% plotly::add_trace(x = ~date, y = ~X7_day_ave_clarke,
type = "scatter",
mode = "lines",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Seven-Day Moving Average: ', X7_day_ave_clarke),
name = "Seven Day Moving Average Athens",
line = list(color = seven_day_ave_color),
showlegend = FALSE)
#renders the main plot layer three as positive target hits
p2 <- plotly::plot_ly() %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n1,
symbol = ~Facility,
marker = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
plotly::add_trace(x = ~date, y = ~mean_copy_num_L,
type = "scatter",
mode = "markers",
hoverinfo = "text",
text = ~paste('</br> Date: ', date,
'</br> Facility: ', Facility,
'</br> Target: ', target,
'</br> Copies/L: ', round(mean_copy_num_L, digits = 2)),
data = only_n2,
symbol = ~Facility,
marker = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(yaxis = list(title = "SARS CoV-2 Copies/L",
showline = TRUE,
type = "log",
dtick = 1,
automargin = TRUE)) %>%
layout(legend = list(orientation = "h", x = 0.2, y = -0.3))
#adds the limit of detection dashed line
p2 <- p2 %>% plotly::add_segments(x = as.Date("2021-06-30"),
xend = ~max(date + 10),
y = 3571.429, yend = 3571.429,
opacity = 0.35,
line = list(color = "black", dash = "dash")) %>%
layout(annotations = list(x = as.Date("2021-06-30"), y = 3.8, xref = "x", yref = "y",
text = "Limit of Detection", showarrow = FALSE))
p1
p2
Combine the two main plot pieces as a subplot
#seperate n1 and n2 frames by site
#n1
wrf_a_only_n1 <- subset(only_n1, Facility == "WRF A")
wrf_b_only_n1 <- subset(only_n1, Facility == "WRF B")
wrf_c_only_n1 <- subset(only_n1, Facility == "WRF C")
#n2
wrf_a_only_n2 <- subset(only_n2, Facility == "WRF A")
wrf_b_only_n2 <- subset(only_n2, Facility == "WRF B")
wrf_c_only_n2 <- subset(only_n2, Facility == "WRF C")
#rejoin the old data frames then seperate in to averages for each plant.
wrfa_both <- full_join(wrf_a_only_n1, wrf_a_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfb_both <- full_join(wrf_b_only_n1, wrf_b_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
wrfc_both <- full_join(wrf_c_only_n1, wrf_c_only_n2)%>%
select(c(date, mean_total_copies)) %>%
group_by(date) %>%
summarize_if(is.numeric, mean) %>%
ungroup() %>%
mutate(log_total_copies_both = log10(mean_total_copies))
## Joining, by = c("date", "new_cases_clarke", "cases_cum_clarke", "X7_day_ave_clarke", "Facility", "collection_num", "target", "mean_copy_num_uL_rxn", "mean_copy_num_L", "sd_L", "mean_total_copies", "sd_total_copies", "log_copy_per_L")
#get max date
maxdate <- max(wrfa_both$date)
mindate <- min(wrfa_both$date)
Build loess smoothing figures figures
This makes the individual plots
#**************************************WRF A PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_botha <- ggplot(wrfa_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_botha<<-..y..), method = "loess", color = '#1B9E77',
span = 0.3, n = 232)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_botha
## `geom_smooth()` using formula 'y ~ x'
fit_botha
## [1] 11.53477 11.57286 11.61065 11.64814 11.68533 11.72221 11.75877 11.79498
## [9] 11.83083 11.86634 11.90152 11.93641 11.97103 12.00538 12.03950 12.07337
## [17] 12.10695 12.14024 12.17324 12.20595 12.23837 12.27050 12.30245 12.33428
## [25] 12.36589 12.39722 12.42817 12.45868 12.48865 12.51754 12.54513 12.57178
## [33] 12.59789 12.62383 12.64998 12.67672 12.70441 12.73286 12.76162 12.79026
## [41] 12.81834 12.84542 12.87106 12.89797 12.92803 12.95955 12.99084 13.02023
## [49] 13.04601 13.06651 13.08504 13.10519 13.12565 13.14513 13.16235 13.17601
## [57] 13.18482 13.19076 13.19626 13.20064 13.20325 13.20343 13.20052 13.19385
## [65] 13.18161 13.16340 13.14075 13.11518 13.08820 13.06134 13.03611 13.00819
## [73] 12.97372 12.93500 12.89429 12.85385 12.81596 12.78289 12.75058 12.71445
## [81] 12.67604 12.63687 12.59849 12.56241 12.53017 12.49715 12.45935 12.41919
## [89] 12.37909 12.34147 12.30878 12.28342 12.26433 12.24836 12.23483 12.22306
## [97] 12.21238 12.20209 12.19152 12.18396 12.18191 12.18351 12.18690 12.19021
## [105] 12.19160 12.18919 12.18517 12.18269 12.18127 12.18047 12.17983 12.17888
## [113] 12.17717 12.17406 12.16970 12.16481 12.16014 12.15641 12.15435 12.15471
## [121] 12.15634 12.15780 12.15934 12.16122 12.16368 12.16699 12.17138 12.17745
## [129] 12.18521 12.19408 12.20349 12.21283 12.22155 12.22904 12.23962 12.25631
## [137] 12.27661 12.29803 12.31806 12.33421 12.34398 12.34790 12.34856 12.34655
## [145] 12.34242 12.33676 12.33012 12.32310 12.31625 12.31016 12.30538 12.30251
## [153] 12.30210 12.29776 12.28525 12.26840 12.25099 12.23686 12.22981 12.23364
## [161] 12.24391 12.25408 12.26480 12.27674 12.29057 12.30695 12.32656 12.35343
## [169] 12.38912 12.43058 12.47473 12.51850 12.55883 12.59265 12.62743 12.67152
## [177] 12.72312 12.78047 12.84179 12.90529 12.96920 13.03174 13.09113 13.14560
## [185] 13.19336 13.23264 13.26167 13.27865 13.28586 13.28743 13.28438 13.27774
## [193] 13.26854 13.25780 13.24654 13.22853 13.19913 13.16172 13.11968 13.07641
## [201] 13.03529 12.99971 12.96598 12.92876 12.88897 12.84752 12.80531 12.76325
## [209] 12.72226 12.68092 12.63750 12.59243 12.54613 12.49900 12.45147 12.40396
## [217] 12.35586 12.30640 12.25578 12.20419 12.15180 12.09881 12.04539 11.99153
## [225] 11.93703 11.88185 11.82598 11.76936 11.71197 11.65378 11.59474 11.53482
#assign fits to a vector
both_trenda <- fit_botha
#extract y min and max for each
limits_botha <- ggplot_build(extract_botha)$data
## `geom_smooth()` using formula 'y ~ x'
limits_botha <- as.data.frame(limits_botha)
both_ymina <- limits_botha$ymin
both_ymaxa <- limits_botha$ymax
#reassign dataframes (just to be safe)
work_botha <- wrfa_both
#fill in missing dates to smooth fits
work_botha <- work_botha %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_botha <- work_botha$date
#create a new smooth dataframe to layer
smooth_frame_botha <- data.frame(date_vec_botha, both_trenda, both_ymina, both_ymaxa)
#WRF A
#plot smooth frames
p_wrf_a <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_botha, y = ~both_trenda,
data = smooth_frame_botha,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha,
'</br> Median Log Copies: ', round(both_trenda, digits = 2)),
line = list(color = '#1B9E77', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_botha, ymin = ~both_ymina, ymax = ~both_ymaxa,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_botha, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxa, digits = 2),
'</br> Min Log Copies: ', round(both_ymina, digits = 2)),
name = "",
fillcolor = '#1B9E77',
line = list(color = '#1B9E77')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF A") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfa_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#1B9E77', size = 6, opacity = 0.65))
p_wrf_a
save(p_wrf_a, file = "./site_objects/wrf_a_year2.rda")
#**************************************WRF B PLOT**********************************************
#add trendlines
#extract data from geom_smooth
#both extract
# *********************************span 0.6***********************************
#*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothb <- ggplot(wrfb_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothb<<-..y..), method = "loess", color = '#D95F02',
span = 0.3, n = 232)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothb
## `geom_smooth()` using formula 'y ~ x'
fit_bothb
## [1] 10.68838 10.78481 10.87913 10.97137 11.06156 11.14974 11.23595 11.32019
## [9] 11.40243 11.48262 11.56074 11.63676 11.71064 11.78234 11.85185 11.91910
## [17] 11.98412 12.04695 12.10761 12.16617 12.22265 12.27710 12.32912 12.37846
## [25] 12.42536 12.47009 12.51287 12.55398 12.59364 12.63122 12.66613 12.69875
## [33] 12.72943 12.75856 12.78650 12.81361 12.83777 12.85729 12.87329 12.88686
## [41] 12.89909 12.91109 12.92393 12.93535 12.94299 12.94792 12.95118 12.95382
## [49] 12.95688 12.96141 12.96774 12.97503 12.98257 12.98966 12.99561 12.99971
## [57] 13.00126 12.99932 12.99414 12.98682 12.97842 12.97002 12.96272 12.95759
## [65] 12.95200 12.94337 12.93281 12.92145 12.91040 12.90079 12.89373 12.89005
## [73] 12.88901 12.88938 12.88990 12.88935 12.88649 12.88007 12.87334 12.86937
## [81] 12.86673 12.86396 12.85960 12.85220 12.84031 12.82411 12.80522 12.78440
## [89] 12.76238 12.73991 12.71775 12.69662 12.67220 12.64128 12.60630 12.56973
## [97] 12.53400 12.50157 12.47489 12.45458 12.43833 12.42421 12.41030 12.39468
## [105] 12.37541 12.35058 12.32234 12.29404 12.26556 12.23677 12.20754 12.17775
## [113] 12.14728 12.10800 12.05583 11.99669 11.93651 11.88120 11.83668 11.80886
## [121] 11.78706 11.75908 11.72861 11.69933 11.67493 11.65909 11.65551 11.66371
## [129] 11.67937 11.70039 11.72468 11.75014 11.77466 11.79615 11.82545 11.87087
## [137] 11.92648 11.98640 12.04471 12.09550 12.13287 12.16400 12.19934 12.23793
## [145] 12.27880 12.32100 12.36355 12.40549 12.44586 12.48369 12.51802 12.54787
## [153] 12.57229 12.58628 12.58851 12.58353 12.57590 12.57014 12.57082 12.58247
## [161] 12.59778 12.60785 12.61482 12.62088 12.62819 12.63892 12.65523 12.68037
## [169] 12.71402 12.75303 12.79424 12.83448 12.87059 12.89941 12.92550 12.95503
## [177] 12.98725 13.02141 13.05676 13.09256 13.12806 13.16251 13.19517 13.22528
## [185] 13.25209 13.27487 13.29286 13.30531 13.31364 13.31981 13.32393 13.32610
## [193] 13.32641 13.32499 13.32191 13.31641 13.30792 13.29688 13.28373 13.26892
## [201] 13.25288 13.23604 13.21787 13.19767 13.17563 13.15195 13.12685 13.10052
## [209] 13.07317 13.04459 13.01446 12.98282 12.94968 12.91506 12.87900 12.84151
## [217] 12.80261 12.76230 12.72053 12.67727 12.63249 12.58615 12.53823 12.48873
## [225] 12.43768 12.38508 12.33095 12.27529 12.21809 12.15938 12.09914 12.03740
#assign fits to a vector
both_trendb <- fit_bothb
#extract y min and max for each
limits_bothb <- ggplot_build(extract_bothb)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothb <- as.data.frame(limits_bothb)
both_yminb <- limits_bothb$ymin
both_ymaxb <- limits_bothb$ymax
#reassign dataframes (just to be safe)
work_bothb <- wrfb_both
#fill in missing dates to smooth fits
work_bothb <- work_bothb %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothb <- work_bothb$date
#create a new smooth dataframe to layer
smooth_frame_bothb <- data.frame(date_vec_bothb, both_trendb, both_yminb, both_ymaxb)
#WRF B
#plot smooth frames
p_wrf_b <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothb, y = ~both_trendb,
data = smooth_frame_bothb,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb,
'</br> Median Log Copies: ', round(both_trendb, digits = 2)),
line = list(color = '#D95F02', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothb, ymin = ~both_yminb, ymax = ~both_ymaxb,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothb, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxb, digits = 2),
'</br> Min Log Copies: ', round(both_yminb, digits = 2)),
name = "",
fillcolor = '#D95F02',
line = list(color = '#D95F02')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF B") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfb_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#D95F02', size = 6, opacity = 0.65))
p_wrf_b
save(p_wrf_b, file = "./site_objects/wrf_b_year2.rda")
#**************************************WRF C PLOT********************************************** #add trendlines #extract data from geom_smooth # *********************************span 0.6*********************************** #*****************Must always update the n = TOTAL NUMBER OF DAYS*************************
extract_bothc <- ggplot(wrfc_both, aes(x = date, y = log_total_copies_both)) +
stat_smooth(aes(outfit=fit_bothc<<-..y..), method = "loess", color = '#E7298A',
span = 0.3, n = 232)
## Warning: Ignoring unknown aesthetics: outfit
#look at the fits to align dates and total observations
#both
extract_bothc
## `geom_smooth()` using formula 'y ~ x'
fit_bothc
## [1] 10.76690 10.84179 10.91505 10.98650 11.05594 11.12321 11.18810 11.25087
## [9] 11.31188 11.37110 11.42855 11.48421 11.53807 11.59013 11.64038 11.68841
## [17] 11.73402 11.77751 11.81914 11.85921 11.89801 11.93582 11.97065 12.00112
## [25] 12.02835 12.05349 12.07767 12.10203 12.12772 12.15313 12.17632 12.19796
## [33] 12.21866 12.23909 12.25988 12.28167 12.30310 12.32275 12.34117 12.35888
## [41] 12.37645 12.39442 12.41334 12.43496 12.45969 12.48607 12.51260 12.53782
## [49] 12.56023 12.57837 12.59307 12.60625 12.61799 12.62839 12.63754 12.64555
## [57] 12.65251 12.66033 12.67003 12.68036 12.69008 12.69793 12.70267 12.70305
## [65] 12.69905 12.69195 12.68246 12.67129 12.65913 12.64671 12.63471 12.61920
## [73] 12.59727 12.57123 12.54338 12.51603 12.49147 12.47201 12.45685 12.44314
## [81] 12.43007 12.41687 12.40272 12.38685 12.36845 12.34684 12.32257 12.29668
## [89] 12.27023 12.24426 12.21982 12.19795 12.17533 12.14912 12.12111 12.09309
## [97] 12.06684 12.04415 12.02682 12.01280 11.99907 11.98595 11.97372 11.96271
## [105] 11.95320 11.94551 11.94133 11.94122 11.94382 11.94774 11.95162 11.95407
## [113] 11.95372 11.95476 11.96089 11.97001 11.98003 11.98883 11.99433 11.99443
## [121] 11.99097 11.98721 11.98325 11.97913 11.97493 11.97073 11.96658 11.95953
## [129] 11.94782 11.93335 11.91798 11.90360 11.89210 11.88536 11.88295 11.88259
## [137] 11.88335 11.88431 11.88456 11.88317 11.87923 11.87223 11.86276 11.85145
## [145] 11.83898 11.82599 11.81314 11.80110 11.79051 11.78204 11.77633 11.77405
## [153] 11.77586 11.77847 11.77912 11.77927 11.78037 11.78387 11.79123 11.80389
## [161] 11.81952 11.83521 11.85147 11.86886 11.88792 11.90918 11.93318 11.96347
## [169] 12.00147 12.04456 12.09015 12.13561 12.17833 12.21571 12.25377 12.29933
## [177] 12.35101 12.40744 12.46722 12.52897 12.59131 12.65285 12.71221 12.76800
## [185] 12.81884 12.86334 12.90013 12.92781 12.94901 12.96736 12.98294 12.99585
## [193] 13.00618 13.01403 13.01949 13.02212 13.02163 13.01827 13.01234 13.00409
## [201] 12.99381 12.98178 12.96585 12.94463 12.91954 12.89198 12.86334 12.83504
## [209] 12.80848 12.78207 12.75344 12.72286 12.69057 12.65682 12.62187 12.58596
## [217] 12.54879 12.50992 12.46941 12.42733 12.38374 12.33870 12.29228 12.24448
## [225] 12.19527 12.14464 12.09259 12.03909 11.98414 11.92773 11.86985 11.81049
#assign fits to a vector
both_trendc <- fit_bothc
#extract y min and max for each
limits_bothc <- ggplot_build(extract_bothc)$data
## `geom_smooth()` using formula 'y ~ x'
limits_bothc <- as.data.frame(limits_bothc)
both_yminc <- limits_bothc$ymin
both_ymaxc <- limits_bothc$ymax
#reassign dataframes (just to be safe)
work_bothc <- wrfc_both
#fill in missing dates to smooth fits
work_bothc <- work_bothc %>% complete(date = seq(min(date), max(date), by = "1 day"))
date_vec_bothc <- work_bothc$date
#create a new smooth dataframe to layer
smooth_frame_bothc <- data.frame(date_vec_bothc, both_trendc, both_yminc, both_ymaxc)
#WRF C
#plot smooth frames
p_wrf_c <- plotly::plot_ly() %>%
plotly::add_lines(x = ~date_vec_bothc, y = ~both_trendc,
data = smooth_frame_bothc,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc,
'</br> Median Log Copies: ', round(both_trendc, digits = 2)),
line = list(color = '#E7298A', size = 8, opacity = 0.65),
showlegend = FALSE) %>%
layout(xaxis = list(range = c(mindate - 7, maxdate + 7))) %>% #buffer here
plotly::add_ribbons(x ~date_vec_bothc, ymin = ~both_yminc, ymax = ~both_ymaxc,
showlegend = FALSE,
opacity = 0.25,
hoverinfo = "text",
text = ~paste('</br> Date: ', date_vec_bothc, #leaving in case we want to change
'</br> Max Log Copies: ', round(both_ymaxc, digits = 2),
'</br> Min Log Copies: ', round(both_yminc, digits = 2)),
name = "",
fillcolor = '#E7298A',
line = list(color = '#E7298A')) %>%
layout(yaxis = list(title = "Total Log10 SARS CoV-2 Copies",
showline = TRUE,
automargin = TRUE)) %>%
layout(xaxis = list(title = "Date")) %>%
layout(title = "WRF C") %>%
plotly::add_markers(x = ~date, y = ~log_total_copies_both,
data = wrfc_both,
hoverinfo = "text",
showlegend = FALSE,
text = ~paste('</br> Date: ', date,
'</br> Actual Log Copies: ', round(log_total_copies_both, digits = 2)),
marker = list(color = '#E7298A', size = 6, opacity = 0.65))
p_wrf_c
save(p_wrf_c, file = "./site_objects/wrf_c_year2.rda")
keeping in case
#save(wrfa_both, file = "./plotly_objs/wrfa_both.rda")
#save(wrfb_both, file = "./plotly_objs/wrfb_both.rda")
#save(wrfc_both, file = "./plotly_objs/wrfc_both.rda")
#save(date_vec_botha, file = "./plotly_objs/date_vec_botha.rda")
#save(date_vec_bothb, file = "./plotly_objs/date_vec_bothb.rda")
#save(date_vec_bothc, file = "./plotly_objs/date_vec_bothc.rda")
#save(both_ymina, file = "./plotly_objs/both_ymina.rda")
#save(both_ymaxa, file = "./plotly_objs/both_ymaxa.rda")
#save(both_yminb, file = "./plotly_objs/both_yminb.rda")
#save(both_ymaxb, file = "./plotly_objs/both_ymaxb.rda")
#save(both_yminc, file = "./plotly_objs/both_yminc.rda")
#save(both_ymaxc, file = "./plotly_objs/both_ymaxc.rda")